/*
 * Copyright 2007 www.luzand.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Depends on: ComponentsFactory.js,Factory.js

function yrprxResourceBundle(url)
{
    if (!url) throw "URL to resource file is missing";

    try
    {
        this.stringBundle = yrprxComponentsFactory.getStringBundleService().createBundle(url);
        // copy to use as map
        for (var enumerator = this.stringBundle.getSimpleEnumeration(); enumerator.hasMoreElements(); )
        {
            var property = enumerator.getNext().QueryInterface(Components.interfaces.nsIPropertyElement);
            this[property.key] = property.value;
        }
    }
    catch(ex)
    {
        this.stringBundle = null;

        try
        {
            var logger = yrprxFactory.createLogger("yrprxResourceBundle");

            if (logger.enabled) logger.error("Exception: " + ex);
        }
        catch(ex)
        {
            dump(ex);
        }
    }
}

yrprxResourceBundle.prototype.getString = function(name)
{
    return this.stringBundle.GetStringFromName(name);
}

var wsshResources = new yrprxResourceBundle("chrome://webslideshow/locale/Resources.properties");